﻿using LightCAD.Core.Elements;
using System.Collections.ObjectModel;
using System.Reflection.Metadata;

namespace LightCAD.Core
{
    public class LcBlock : ElementSet
    {
        public static void Save(LcBlock block, string filePath)
        {
        }
        public static LcBlock Load(string filePath)
        {
            //TODO:Load(filePath,asBlock);如果作为块加载，很多内容忽略
            var doc = DocumentUtils.Load(filePath, true);
            //Merge doc.Layers
            //Merge doc.LineType
            //Merge......

            return null;
        }
         

        private Box2d? boundingBox;
        public string Name { get; set; }
        public string Description { get; set; }
        public Vector2d BasePoint { get; set; }
        public bool AllowAttribute { get; set; }

        public Box2d BoundingBox
        {
            get
            {
                if (boundingBox == null)
                {
                    boundingBox = GetBoundingBox();
                }
                return boundingBox.Value;
            }
        }
        public void ResetBoundingBox()
        {
            this.boundingBox = null;
        }
        public virtual Box2d GetBoundingBox()
        {
            return Box2d.Zero;
        }

        public LcAttribute[] GetAttributes()
        {
            return null;
        }
    }

    public class LcBlockCollection : KeyedCollection<long, LcBlock>
    {
        protected override long GetKeyForItem(LcBlock item)
        {
            return item.Id;
        }
    }
}